package com.kanqiubao.kq.adapter.search;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.kanqiubao.kq.R;

import java.util.ArrayList;
import java.util.List;


/**
 * 创建团标签
 */
public class SearchTagGroupAdapter extends BaseAdapter {

    private Context mContext;
    private List<String> mList=new ArrayList<>();

    public SearchTagGroupAdapter(Context mContext) {
        this.mContext = mContext;
    }

    public void addData(String s) {
        if (mList == null) {
            mList = new ArrayList<>();
        }
        mList.add(0,s);
        notifyDataSetChanged();
    }
    public void addData(List<String> list) {
        if (mList == null) {
            mList = new ArrayList<>();
        }
        mList.addAll(list);
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public String getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.search_tag_group_item, null);
            holder = new ViewHolder();
            holder.tagBtn = (TextView) convertView.findViewById(R.id.group_tag_item_txt_id);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
//        if(getItem(position).isSelect()){
//            holder.tagBtn.setBackgroundResource(R.drawable.shape_tag_select_item_bg);
//            holder.tagBtn.setTextColor(ThisAppApplication.getInstance().getResources().getColor(R.color.kc_detail_tab_txt_color));
//        }else{
//            holder.tagBtn.setBackgroundResource(R.drawable.shape_tag_item_bg);
//            holder.tagBtn.setTextColor(ThisAppApplication.getInstance().getResources().getColor(R.color.app_tool_bar));
//
//        }
        final String text = getItem(position);
        holder.tagBtn.setText(text);
        return convertView;
    }

    static class ViewHolder {
        TextView tagBtn;
    }
}
